package hp.com.servlet.UsersServlet;

import hp.com.entity.Users;
import hp.com.service.UsersService;
import hp.com.service.impl.UsersServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/UpdateInfo")
public class MemberSafeServlet extends HttpServlet {
    private UsersService usersService = new UsersServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //判断是否登录且获取对象
        HttpSession session = req.getSession();
        if(session.getAttribute("userSession")==null){
            resp.sendRedirect(req.getContextPath()+"/jbs/Login.jsp");
        }
        try {
            Users users =(Users)session.getAttribute("userSession");
            req.setAttribute("users",users);
            req.getRequestDispatcher("easybuy/Member_Safe.jsp").forward(req,resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
